<template>
  <div id='main'>
    <input type="text" placeholder="请输入文章标题..." v-model="param.title">
    <!-- <img src="" alt=""> -->
    <mavon-editor
      v-model="param.content"
      ref=md
      :editable='true'
      :toolbarsFlag='true'
      @imgAdd="$imgAdd"
    />
  </div>
</template>

<script>
import BLL from './bll'
// import http from '../../server/xhttp'
export default {
  name: 'createArticle',
  data () {
    return {
      param: {
        title: '',
        content: ''
      }
    }
  },
  created () {
    this.bll = new BLL(this)
    if (this.$route.params.articleId) {
      this.bll.getArticle()
    }
  },
  watch: {
    param: {
      handler (editingArticle) {
        this.$store.commit('SET_ARTICLE', editingArticle)
      },
      deep: true
    }
  },
  methods: {
    // 绑定@imgAdd event
    $imgAdd (pos, $file) {
      this.$refs.md.$img2Url(pos, $file.miniurl)
    },
    $imgDel (pos) {
      delete this.img_file[pos]
    }
  }
}
</script>

<style lang="less" scoped>
@import url('./create');
</style>
